<template>
    <div class="top-bar" @touchmove.prevent>
        <div class="body">
            <div class="icon menu" @click="switchMenuList">
                <img
                    v-show="!showMenu"
                    :src="require(`@/assets/icon/menu_light.png`)"
                />
                <img
                    v-show="showMenu"
                    :src="require(`@/assets/icon/close_v2_ligtht.png`)"
                />
            </div>

            <div class="home" @click="toPage('/home')">贝壳</div>

            <div class="icon profile" @click="toPage('/profile')">
                <img :src="require(`@/assets/icon/profile_light.png`)" />
            </div>
        </div>
        <MenuList v-model="showMenu" :list="menuList" @page-click="toPage" />
    </div>
</template>

<script>
import MenuList from "./menuList";
export default {
    components: {
        MenuList
    },
    data() {
        return {
            menuList: [
                { title: "首页", path: "/home" },
                { title: "发现", path: "/discover" },
                { title: "社区", path: "/community/home" },
                { title: "收藏", path: "/collect" },
                { title: "关于", path: "/community/post" }
            ],
            showMenu: false
        };
    },

    methods: {
        toPage(path) {
            this.$router.push({
                path: `${path}`
            });
            this.showMenu = false;
        },

        switchMenuList() {
            this.showMenu = !this.showMenu;
        }
    }
};
</script>


<style lang="less" scoped>
.top-bar {
    position: fixed;
    z-index: 1000;
    top: 0;
    width: 100%;
    height: 100px;

    box-shadow: 0 0 10px rgba(100, 100, 100, 0.2);
    box-sizing: border-box;
    background: #333;
    color: #fff;
    font-size: 30px;

    .body {
        position: relative;
        z-index: 1001;
        display: flex;
        width: 100%;
        height: 100%;
        box-sizing: border-box;
        padding: 25px 30px;
        justify-content: space-between;
        align-items: center;

        .icon {
            width: 45px;
        }

        .profile {
            width: 45px;
        }
    }
}
</style>